package pe.edu.upc.dsd.epica.movil;

import com.google.gson.Gson;
import com.google.gson.JsonParseException;

import pe.edu.upc.dsd.epica.R;
import pe.edu.upc.dsd.epica.model.Promocion;
import pe.edu.upc.dsd.epica.movil.OAuthTwitterActivity;
import pe.edu.upc.dsd.epica.movil.epica;
import pe.edu.upc.dsd.epica.util.RequestMethod;
import pe.edu.upc.dsd.epica.util.RestClient;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;

public class epica extends Activity implements OnClickListener {
	// private static final String TAG = "epica";
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.inicio);

		// Set up click listeners for all the buttons
		View iniciafButton = findViewById(R.id.iniciaf_button);
		iniciafButton.setOnClickListener(this);
		View iniciatButton = findViewById(R.id.iniciat_button);
		iniciatButton.setOnClickListener(this);
		View aboutButton = findViewById(R.id.about_button);
		aboutButton.setOnClickListener(this);
		View exitButton = findViewById(R.id.exit_button);
		
		exitButton.setOnClickListener(this);
	}

	@Override
	protected void onResume() {
		super.onResume();
		Music.play(this, R.raw.main);
	}

	@Override
	protected void onPause() {
		super.onPause();
		Music.stop(this);
	}

	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.iniciaf_button:
			Intent j = new Intent(this, prom_ubica.class);
			startActivity(j);
			break;
		// ...
		case R.id.about_button:
			Intent i = new Intent(this, About.class);
			startActivity(i);
			break;
		// More buttons go here (if any) ...
		case R.id.iniciat_button:
			Intent demoIntent = new Intent(epica.this,
					OAuthTwitterActivity.class);
			startActivity(demoIntent);
			break;
		case R.id.exit_button:
			finish();
			break;
		}
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		super.onCreateOptionsMenu(menu);
		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.menu, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case R.id.settings:
			startActivity(new Intent(this, Prefs.class));
			return true;
			// More items go here (if any) ...
		}
		return false;
	}

	/**
	 * Ask the user what difficulty level they want private void
	 * openNewGameDialog() { new AlertDialog.Builder(this)
	 * .setTitle(R.string.new_game_title) .setItems(R.array.difficulty, new
	 * DialogInterface.OnClickListener() { public void onClick(DialogInterface
	 * dialoginterface, int i) { startGame(i); } }) .show(); }
	 */

	/**
	 * Start a new game with the given difficulty level private void
	 * startGame(int i) { Log.d(TAG, "clicked on " + i); Intent intent = new
	 * Intent(this, Game.class); intent.putExtra(Game.KEY_DIFFICULTY, i);
	 * startActivity(intent); }
	 */
}